Skip to content

SREP-3880: Request AWS additional SQS permissions for ROSA Managed Policies (Spot Instance Support) - #8134

Closed
ratnam915 wants to merge 6 commits into
openshift:mainfrom
ratnam915:feature/SREP-3880
Closed

SREP-3880: Request AWS additional SQS permissions for ROSA Managed Policies (Spot Instance Support)#8134
ratnam915 wants to merge 6 commits into
openshift:mainfrom
ratnam915:feature/SREP-3880

Conversation

@ratnam915

@ratnam915 ratnam915 commented Mar 31, 2026

Copy link
Copy Markdown

PR Refinement: Scope SQS Permissions with red-hat-managed Tag Condition in Nodepool Inline PolicyTarget

Summary

Scope the AWS IAM actions sqs:DeleteMessage and sqs:ReceiveMessage within the nodePoolPolicy inline policy by applying an aws:ResourceTag/red-hat-managed: "true" condition. This change ensures the development/test inline policy aligns with the security posture update in the upcoming ROSANodePoolManagementPolicy managed policy.Change Description
Remove sqs:DeleteMessage and sqs:ReceiveMessage from the existing general statement (the one encompassing all EC2 actions and Resource: [""]).
Add a new, separate statement after the existing ones:
{
"Sid": "NodePoolSQSActions",
"Effect": "Allow",
"Action": [
"sqs:DeleteMessage",
"sqs:ReceiveMessage"
],
"Resource": "
",
"Condition": {
"StringEquals": {
"aws:ResourceTag/red-hat-managed": "true"
}
}
}

Reference
Enhancement: https://github.com/openshift/enhancements/pull/1951
NTH Implementation: https://github.com/openshift/hypershift/pull/7567
API Changes: https://github.com/openshift/hypershift/pull/7625
Jira: OCPSTRAT-1677 / SREP-698

Summary by CodeRabbit

  • Chores
    • SQS delete/receive permissions are now restricted by a required resource tag, tightening access to queues that carry that tag.
  • New Features
    • Added API support to tag queues so resources can be marked for the new tag-restricted operations.
  • Tests
    • E2E tests updated to create queues with the required tag to validate the tag-based access restriction.

@openshift-ci-robot

Copy link
Copy Markdown

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Mar 31, 2026
@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 31, 2026
@openshift-ci

openshift-ci Bot commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci-robot

openshift-ci-robot commented Mar 31, 2026

Copy link
Copy Markdown

@ratnam915: This pull request references SREP-3880 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

PR Refinement: Scope SQS Permissions with red-hat-managed Tag Condition in Nodepool Inline PolicyTarget

Summary

Scope the AWS IAM actions sqs:DeleteMessage and sqs:ReceiveMessage within the nodePoolPolicy inline policy by applying an aws:ResourceTag/red-hat-managed: "true" condition. This change ensures the development/test inline policy aligns with the security posture update in the upcoming ROSANodePoolManagementPolicy managed policy.Change Description
Remove sqs:DeleteMessage and sqs:ReceiveMessage from the existing general statement (the one encompassing all EC2 actions and Resource: [""]).
Add a new, separate statement after the existing ones:
{
"Sid": "NodePoolSQSActions",
"Effect": "Allow",
"Action": [
"sqs:DeleteMessage",
"sqs:ReceiveMessage"
],
"Resource": "
",
"Condition": {
"StringEquals": {
"aws:ResourceTag/red-hat-managed": "true"
}
}
}

Reference
Enhancement: https://github.com/openshift/enhancements/pull/1951
NTH Implementation: https://github.com/openshift/hypershift/pull/7567
API Changes: https://github.com/openshift/hypershift/pull/7625
Jira: OCPSTRAT-1677 / SREP-698

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai

coderabbitai Bot commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The IAM policy nodePoolPolicy in cmd/infra/aws/iam.go was changed: sqs:DeleteMessage and sqs:ReceiveMessage were removed from the main actions list and added in a separate statement (Sid: NodePoolSQSActions) that allows those actions on "*" only when the queue has the tag aws:ResourceTag/red-hat equal to "true". The exported SQSAPI interface (support/awsapi/sqs.go) gained a TagQueue method and the delegating client generator was updated to include TagQueue for SQS. The e2e test now tags the created SQS queue with red-hat=true.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Test as Test/Operator
participant IAM as AWS IAM
participant SQS as SQS Service
participant NodePool as NodePool (instance)

Test->>SQS: CreateQueue (Tags: red-hat=true)
SQS-->>Test: Queue URL
Test->>IAM: Attach nodePoolPolicy (includes condition on aws:ResourceTag/red-hat == "true")
Note right of IAM: Policy contains NodePoolSQSActions for Receive/Delete with Condition
NodePool->>SQS: ReceiveMessage / DeleteMessage
SQS->>IAM: Evaluate request (check aws:ResourceTag/red-hat)
IAM-->>SQS: Allow (if tag == "true") or Deny
SQS-->>NodePool: Return message or AccessDenied
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

Timed out fetching pipeline failures after 30000ms


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci Bot added do-not-merge/needs-area area/cli Indicates the PR includes changes for CLI labels Mar 31, 2026
@openshift-ci

openshift-ci Bot commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ratnam915
Once this PR has been reviewed and has the lgtm label, please assign jparrill for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added area/platform/aws PR/issue for AWS (AWSPlatform) platform and removed do-not-merge/needs-area labels Mar 31, 2026
@codecov

codecov Bot commented Mar 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 41.50%. Comparing base (a6c3012) to head (9003dc6).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8134   +/-   ##
=======================================
  Coverage   41.50%   41.50%           
=======================================
  Files         758      758           
  Lines       93689    93689           
=======================================
  Hits        38882    38882           
  Misses      52070    52070           
  Partials     2737     2737           
Files with missing lines Coverage Δ
cmd/infra/aws/delegatingclientgenerator/main.go 0.00% <ø> (ø)
cmd/infra/aws/iam.go 29.02% <ø> (ø)
Flag Coverage Δ
cmd-support 34.86% <ø> (ø)
cpo-hostedcontrolplane 43.59% <ø> (ø)
cpo-other 43.17% <ø> (ø)
hypershift-operator 51.57% <ø> (ø)
other 31.64% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread cmd/infra/aws/iam.go Outdated
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:ResourceTag/red-hat-managed": "true"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should be red-hat: true since it is not actually redhat managed it is more like a shared resource. Would that be a correct?

Managed tag is mostly used for resources created as part of install or RH setup instead of customer input

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

red-hat-managed: true is for things we manage.
red-hat: true is for things that are part of the platform but not necessarily managed by Red Hat.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those perms are for selfhosted hcp, they don't impact rosa in any way.
You'll want to include that in the rosa managed policy. Besides, what guarantees the sqs has that tag in rosa?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gdbranco @arendej : This has been fixed now, thanks for the suggestion.

@enxebre : You're right — the inline policy in iam.go is for self-hosted HCP and doesn't directly impact ROSA, which uses AWS managed policies. The managed policy update to
ROSANodePoolManagementPolicy is being tracked separately via the AWS submission process https://redhat.atlassian.net/browse/SREP-3880?focusedCommentId=16584538

This change aligns the self-hosted inline policy with the tag condition that will be included in the managed policy update, so that dev/test environments using inline
policies surface any permission issues early rather than only in ROSA with managed policies.

Add required IAM permissions to support infrastructure provisioning.
Correct IAM permission configuration per review comments.
@ratnam915
ratnam915 force-pushed the feature/SREP-3880 branch from 803e11e to ce32fa8 Compare April 6, 2026 09:47
@ratnam915

Copy link
Copy Markdown
Author

@gdbranco @arendej @enxebre : Could you help out with the review for the latest changes

@ratnam915
ratnam915 marked this pull request as ready for review April 8, 2026 11:27
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 8, 2026
@openshift-ci
openshift-ci Bot requested review from devguyio and jparrill April 8, 2026 11:28
@openshift-ci-robot

openshift-ci-robot commented Apr 8, 2026

Copy link
Copy Markdown

@ratnam915: This pull request references SREP-3880 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

PR Refinement: Scope SQS Permissions with red-hat-managed Tag Condition in Nodepool Inline PolicyTarget

Summary

Scope the AWS IAM actions sqs:DeleteMessage and sqs:ReceiveMessage within the nodePoolPolicy inline policy by applying an aws:ResourceTag/red-hat-managed: "true" condition. This change ensures the development/test inline policy aligns with the security posture update in the upcoming ROSANodePoolManagementPolicy managed policy.Change Description
Remove sqs:DeleteMessage and sqs:ReceiveMessage from the existing general statement (the one encompassing all EC2 actions and Resource: [""]).
Add a new, separate statement after the existing ones:
{
"Sid": "NodePoolSQSActions",
"Effect": "Allow",
"Action": [
"sqs:DeleteMessage",
"sqs:ReceiveMessage"
],
"Resource": "
",
"Condition": {
"StringEquals": {
"aws:ResourceTag/red-hat-managed": "true"
}
}
}

Reference
Enhancement: https://github.com/openshift/enhancements/pull/1951
NTH Implementation: https://github.com/openshift/hypershift/pull/7567
API Changes: https://github.com/openshift/hypershift/pull/7625
Jira: OCPSTRAT-1677 / SREP-698

Summary by CodeRabbit

  • Chores
  • Updated cloud access control policies to enforce stricter restrictions on queue service operations using resource-level tagging.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@cmd/infra/aws/iam.go`:
- Line 526: The IAM policy condition uses the wrong tag key
"aws:ResourceTag/red-hat"; change it to "aws:ResourceTag/red-hat-managed" so it
matches the actual resource tag used across the codebase (see where
support/awsutil/platform.go checks tag.Key == "red-hat-managed" and
cmd/cluster/aws/create.go appends red-hat-managed=true); update the string
literal in the IAM policy definition in cmd/infra/aws/iam.go to
"aws:ResourceTag/red-hat-managed".
- Around line 516-529: Add a TagQueue method to the SQSAPI interface and ensure
all queue creation paths tag queues with "red-hat":"true"; specifically, modify
support/awsapi/sqs.go to add TagQueue(ctx context.Context, input
*sqs.TagQueueInput) (*sqs.TagQueueOutput, error) (or equivalent signature used
elsewhere), then update every place that creates or initializes queues (e.g.,
calls to CreateQueue or any helper like CreateSQSQueue/CreateQueueIfNotExists)
to include the tag either in CreateQueueInput.Tags or immediately call
SQSAPI.TagQueue after creation using the returned QueueUrl/QueueArn; ensure
callers import and use the new method name (TagQueue) and handle errors returned
from tagging.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 67d1a0bb-22ad-4ebc-b0dc-3188c297e00b

📥 Commits

Reviewing files that changed from the base of the PR and between 51af991 and ce32fa8.

📒 Files selected for processing (1)
  • cmd/infra/aws/iam.go

Comment thread cmd/infra/aws/iam.go
Comment thread cmd/infra/aws/iam.go
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:ResourceTag/red-hat": "true"

@coderabbitai coderabbitai Bot Apr 8, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Verify tag key consistency and check for both variants

echo "=== Searching for 'red-hat-managed' tag usage ==="
rg -n 'red-hat-managed' --type=go -C3

echo -e "\n=== Searching for 'red-hat' tag usage (without '-managed') ==="
rg -n '"red-hat":\s*"true"' --type=go -C3

echo -e "\n=== Checking IAM policies for tag conditions ==="
rg -nP 'aws:ResourceTag/(red-hat|red-hat-managed)' --type=go -C3

Repository: openshift/hypershift

Length of output: 10216


Fix tag key mismatch in IAM policy condition.

The IAM policy at line 526 uses aws:ResourceTag/red-hat, but the actual infrastructure tags across the codebase use red-hat-managed=true:

  • support/awsutil/platform.go:14 checks for tag.Key == "red-hat-managed"
  • cmd/cluster/aws/create.go:121 appends red-hat-managed=true to resource tags
  • The webhook and tests all reference red-hat-managed

The IAM condition must be changed to aws:ResourceTag/red-hat-managed to match the tags actually applied to resources. With the current code, the policy condition will never match, resulting in access denied errors.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmd/infra/aws/iam.go` at line 526, The IAM policy condition uses the wrong
tag key "aws:ResourceTag/red-hat"; change it to
"aws:ResourceTag/red-hat-managed" so it matches the actual resource tag used
across the codebase (see where support/awsutil/platform.go checks tag.Key ==
"red-hat-managed" and cmd/cluster/aws/create.go appends red-hat-managed=true);
update the string literal in the IAM policy definition in cmd/infra/aws/iam.go
to "aws:ResourceTag/red-hat-managed".

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@apwatchtoolbuilder-dev, understood — thank you for the clarification. The distinction makes sense: red-hat-managed=true is the existing general-purpose infrastructure tag for EC2/general resources, while red-hat=true is a new, purpose-built tag for SQS queues used by the spot termination handler. Since the IAM condition, the test inline policy, and the queue-creation tags are all internally consistent with this new tag, there's no mismatch.

I'll record this for future reviews.


✏️ Learnings added
Learnt from: apwatchtoolbuilder-dev
Repo: openshift/hypershift PR: 8134
File: cmd/infra/aws/iam.go:526-526
Timestamp: 2026-06-09T15:13:31.297Z
Learning: In the openshift/hypershift repository (cmd/infra/aws/iam.go and related files), there are two distinct AWS resource tags with different scopes:
1. `red-hat-managed=true` — the existing general-purpose tag applied to EC2 and general infrastructure resources (checked in support/awsutil/platform.go and appended in cmd/cluster/aws/create.go).
2. `red-hat=true` — a new, separate tag scoped specifically to SQS queues for the spot termination handler (SREP-3880 / NodePool spot instance support). The IAM policy condition `aws:ResourceTag/red-hat` in the `NodePoolSQSActions` statement and the queue tagging in the e2e tests are intentionally consistent with each other and are NOT a mismatch with `red-hat-managed`.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@openshift-ci openshift-ci Bot added area/control-plane-operator Indicates the PR includes changes for the control plane operator - in an OCP release area/hypershift-operator Indicates the PR includes changes for the hypershift operator and API - outside an OCP release area/testing Indicates the PR includes changes for e2e testing labels Apr 9, 2026
@openshift-ci-robot

openshift-ci-robot commented Apr 9, 2026

Copy link
Copy Markdown

@ratnam915: This pull request references SREP-3880 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

PR Refinement: Scope SQS Permissions with red-hat-managed Tag Condition in Nodepool Inline PolicyTarget

Summary

Scope the AWS IAM actions sqs:DeleteMessage and sqs:ReceiveMessage within the nodePoolPolicy inline policy by applying an aws:ResourceTag/red-hat-managed: "true" condition. This change ensures the development/test inline policy aligns with the security posture update in the upcoming ROSANodePoolManagementPolicy managed policy.Change Description
Remove sqs:DeleteMessage and sqs:ReceiveMessage from the existing general statement (the one encompassing all EC2 actions and Resource: [""]).
Add a new, separate statement after the existing ones:
{
"Sid": "NodePoolSQSActions",
"Effect": "Allow",
"Action": [
"sqs:DeleteMessage",
"sqs:ReceiveMessage"
],
"Resource": "
",
"Condition": {
"StringEquals": {
"aws:ResourceTag/red-hat-managed": "true"
}
}
}

Reference
Enhancement: https://github.com/openshift/enhancements/pull/1951
NTH Implementation: https://github.com/openshift/hypershift/pull/7567
API Changes: https://github.com/openshift/hypershift/pull/7625
Jira: OCPSTRAT-1677 / SREP-698

Summary by CodeRabbit

  • Chores
  • Tightened cloud access control: SQS delete/receive permissions now require a specific resource tag to apply.
  • New Features
  • Added support for tagging queues via the service API.
  • Tests
  • End-to-end tests updated to create queues with the required tag to validate the new restrictions.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@ratnam915
ratnam915 force-pushed the feature/SREP-3880 branch from ab28b72 to 585df87 Compare April 9, 2026 05:16
@openshift-ci-robot

openshift-ci-robot commented Apr 9, 2026

Copy link
Copy Markdown

@ratnam915: This pull request references SREP-3880 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

PR Refinement: Scope SQS Permissions with red-hat-managed Tag Condition in Nodepool Inline PolicyTarget

Summary

Scope the AWS IAM actions sqs:DeleteMessage and sqs:ReceiveMessage within the nodePoolPolicy inline policy by applying an aws:ResourceTag/red-hat-managed: "true" condition. This change ensures the development/test inline policy aligns with the security posture update in the upcoming ROSANodePoolManagementPolicy managed policy.Change Description
Remove sqs:DeleteMessage and sqs:ReceiveMessage from the existing general statement (the one encompassing all EC2 actions and Resource: [""]).
Add a new, separate statement after the existing ones:
{
"Sid": "NodePoolSQSActions",
"Effect": "Allow",
"Action": [
"sqs:DeleteMessage",
"sqs:ReceiveMessage"
],
"Resource": "
",
"Condition": {
"StringEquals": {
"aws:ResourceTag/red-hat-managed": "true"
}
}
}

Reference
Enhancement: https://github.com/openshift/enhancements/pull/1951
NTH Implementation: https://github.com/openshift/hypershift/pull/7567
API Changes: https://github.com/openshift/hypershift/pull/7625
Jira: OCPSTRAT-1677 / SREP-698

Summary by CodeRabbit

  • Chores
  • Tightened SQS access: delete/receive permissions now apply only when a specific resource tag is present.
  • New Features
  • Added API support for tagging queues.
  • Tests
  • E2E tests updated to create queues with the required tag to validate the new tag-based access restriction.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Add TagQueue method to SQSAPI interface in support/awsapi/sqs.go and
tag SQS queues with "red-hat":"true" at creation time in the e2e test
to match the IAM policy condition on aws:ResourceTag/red-hat.
@ratnam915
ratnam915 force-pushed the feature/SREP-3880 branch from 585df87 to 45db83b Compare April 9, 2026 05:37
@openshift-ci-robot

openshift-ci-robot commented Apr 9, 2026

Copy link
Copy Markdown

@ratnam915: This pull request references SREP-3880 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

PR Refinement: Scope SQS Permissions with red-hat-managed Tag Condition in Nodepool Inline PolicyTarget

Summary

Scope the AWS IAM actions sqs:DeleteMessage and sqs:ReceiveMessage within the nodePoolPolicy inline policy by applying an aws:ResourceTag/red-hat-managed: "true" condition. This change ensures the development/test inline policy aligns with the security posture update in the upcoming ROSANodePoolManagementPolicy managed policy.Change Description
Remove sqs:DeleteMessage and sqs:ReceiveMessage from the existing general statement (the one encompassing all EC2 actions and Resource: [""]).
Add a new, separate statement after the existing ones:
{
"Sid": "NodePoolSQSActions",
"Effect": "Allow",
"Action": [
"sqs:DeleteMessage",
"sqs:ReceiveMessage"
],
"Resource": "
",
"Condition": {
"StringEquals": {
"aws:ResourceTag/red-hat-managed": "true"
}
}
}

Reference
Enhancement: https://github.com/openshift/enhancements/pull/1951
NTH Implementation: https://github.com/openshift/hypershift/pull/7567
API Changes: https://github.com/openshift/hypershift/pull/7625
Jira: OCPSTRAT-1677 / SREP-698

Summary by CodeRabbit

  • Chores
  • SQS delete/receive permissions are now restricted by a required resource tag, tightening access to queues that carry that tag.
  • New Features
  • Added API support to tag queues so resources can be marked for the new tag-restricted operations.
  • Tests
  • E2E tests updated to create queues with the required tag to validate the tag-based access restriction.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/e2e/nodepool_spot_termination_handler_test.go`:
- Around line 151-153: The test attaches an inline IAM policy that grants
sqs:ReceiveMessage and sqs:DeleteMessage without enforcing the
aws:ResourceTag/red-hat tag condition, so the test bypasses the production gate;
update the test's inline policy (the block at Lines ~113–125 that grants SQS
actions) to include a Condition enforcing "StringEquals":
{"aws:ResourceTag/red-hat": "true"} for those actions (or alternately scope the
policy to the specific SQS resource ARN that has the Tags map set in the test),
keeping the Tags map (the "red-hat": "true" entry around Line 151) as the tag
that satisfies the condition.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: a898f08c-512c-465e-91dc-2cf1415f7727

📥 Commits

Reviewing files that changed from the base of the PR and between 585df87 and 45db83b.

📒 Files selected for processing (3)
  • cmd/infra/aws/delegatingclientgenerator/main.go
  • support/awsapi/sqs.go
  • test/e2e/nodepool_spot_termination_handler_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • support/awsapi/sqs.go

Comment thread test/e2e/nodepool_spot_termination_handler_test.go
Add StringEquals condition for aws:ResourceTag/red-hat to the test's
inline IAM policy so it matches the production gate rather than
granting unconditional SQS access.
@ratnam915 ratnam915 closed this Apr 9, 2026
@ratnam915 ratnam915 reopened this Apr 9, 2026
@openshift-ci-robot

openshift-ci-robot commented Apr 9, 2026

Copy link
Copy Markdown

@ratnam915: This pull request references SREP-3880 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

PR Refinement: Scope SQS Permissions with red-hat-managed Tag Condition in Nodepool Inline PolicyTarget

Summary

Scope the AWS IAM actions sqs:DeleteMessage and sqs:ReceiveMessage within the nodePoolPolicy inline policy by applying an aws:ResourceTag/red-hat-managed: "true" condition. This change ensures the development/test inline policy aligns with the security posture update in the upcoming ROSANodePoolManagementPolicy managed policy.Change Description
Remove sqs:DeleteMessage and sqs:ReceiveMessage from the existing general statement (the one encompassing all EC2 actions and Resource: [""]).
Add a new, separate statement after the existing ones:
{
"Sid": "NodePoolSQSActions",
"Effect": "Allow",
"Action": [
"sqs:DeleteMessage",
"sqs:ReceiveMessage"
],
"Resource": "
",
"Condition": {
"StringEquals": {
"aws:ResourceTag/red-hat-managed": "true"
}
}
}

Reference
Enhancement: https://github.com/openshift/enhancements/pull/1951
NTH Implementation: https://github.com/openshift/hypershift/pull/7567
API Changes: https://github.com/openshift/hypershift/pull/7625
Jira: OCPSTRAT-1677 / SREP-698

Summary by CodeRabbit

  • Chores
  • SQS delete/receive permissions are now restricted by a required resource tag, tightening access to queues that carry that tag.
  • New Features
  • Added API support to tag queues so resources can be marked for the new tag-restricted operations.
  • Tests
  • E2E tests updated to create queues with the required tag to validate the tag-based access restriction.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@jparrill

jparrill commented May 5, 2026

Copy link
Copy Markdown
Contributor

/uncc

@openshift-ci
openshift-ci Bot removed the request for review from jparrill May 5, 2026 09:34
@ratnam915

Copy link
Copy Markdown
Author

@coderabbitai

  1. iam.go:529 — Add TagQueue / implement queue tagging (Critical)
    Addressed. TagQueue has been added to the SQSAPI interface in support/awsapi/sqs.go, registered in delegatingclientgenerator/main.go, and the test's CreateQueue call
    now includes Tags: map[string]string{"red-hat": "true"} to tag queues at creation time.

  2. iam.go:526 — Tag key mismatch red-hat vs red-hat-managed (Critical)
    This is intentional — not a mismatch. The red-hat-managed tag is used for EC2 and general infrastructure resources. The red-hat tag introduced here is a new, separate
    tag scoped specifically to SQS queues for the spot termination handler feature. The IAM policy condition (aws:ResourceTag/red-hat), the inline test policy, and the
    queue creation tags are all consistent with each other within this feature.

  3. nodepool_spot_termination_handler_test.go:158 — Test bypasses IAM tag gate (Major)
    Addressed. The test's inline IAM policy now includes a Condition block enforcing "StringEquals": {"aws:ResourceTag/red-hat": "true"}, and the SQS queue is created with
    the matching red-hat: true tag. The test will now correctly fail if the tag-based enforcement regresses.

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Resolve my own review comments on PR `#8134` related to these three points
gh pr view 8134 --repo openshift/hypershift --comments --json comments | jq '.comments[] | select(.author.login == "coderabbitai") | {id: .id, body: .body[0:100]}'

Length of output: 444


🏁 Script executed:

#!/bin/bash
# Fetch inline review comments made by coderabbitai on PR `#8134`
gh api repos/openshift/hypershift/pulls/8134/comments \
  --jq '.[] | select(.user.login == "coderabbitai") | {id: .id, path: .path, body: .body[0:120]}'

Length of output: 472


🏁 Script executed:

#!/bin/bash
# Fetch all reviews on PR `#8134` by coderabbitai
gh api repos/openshift/hypershift/pulls/8134/reviews \
  --jq '.[] | select(.user.login == "coderabbitai") | {id: .id, state: .state, body: .body[0:100]}'

Length of output: 457



@ratnam915 It looks like the related review comments on this PR have already been resolved (no open inline comments were found). All three points are acknowledged:

  • Items 1 & 3 are confirmed addressed via code changes.
  • Item 2 is noted as intentional design — the red-hat tag is purposefully distinct from red-hat-managed for SQS queue scoping in the spot termination handler feature. I've saved this to long-term memory to avoid flagging it in future reviews.

The PR looks good from my end! 🎉

@hypershift-jira-solve-ci

hypershift-jira-solve-ci Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Now I have all the evidence needed. Let me produce the final report.

Test Failure Analysis Complete

Job Information

  • Prow Job: codecov/project (Codecov GitHub Check — not a Prow CI job)
  • Build ID: Check Run 80358359957
  • PR: #8134SREP-3880: Request AWS additional SQS permissions for ROSA Managed Policies (Spot Instance Support)
  • Base Commit: a6c3012 (main, 2026-06-09)
  • Head Commit: 9003dc6

Test Failure Analysis

Error

codecov/project: 41.42% (-0.08%) compared to a6c3012
Project coverage dropped from 41.50% to 41.42% (-0.08%).

Summary

The codecov/project check failed because overall project-wide code coverage dropped by 0.08% compared to the base commit. Critically, none of the PR's own code changes caused the drop — Codecov explicitly confirms "All modified and coverable lines are covered by tests" and every changed file shows (ø) (zero coverage delta). The drop is caused entirely by 9 indirect files whose coverage shifted due to carry-forward flag staleness. The sibling codecov/patch check passed successfully, confirming the PR's changes are not the issue.

Root Cause

The root cause is carry-forward coverage data staleness interacting with Codecov's default project-level threshold.

  1. Carry-forward flags: The repository's codecov.yml configures carryforward: true for all five coverage flags (cpo-hostedcontrolplane, cpo-other, hypershift-operator, cmd-support, other). This means when a CI run for a flag doesn't execute on the PR commit, Codecov reuses coverage data from a previous run.

  2. Default threshold of 0%: The codecov.yml has no explicit coverage.status.project configuration. Codecov's default behavior sets target: auto (match the base commit's coverage) with threshold: 0% (zero tolerance for any drop). Any coverage decrease — even 0.01% — triggers a failure.

  3. Indirect coverage changes in 9 files: Between the base commit (a6c3012) and the PR head (9003dc6), 9 files not modified by this PR experienced coverage changes. These shifts are artifacts of carry-forward data from different CI runs having slightly different execution paths, line counts, or test ordering — not actual regressions in test coverage.

  4. PR changes are coverage-neutral: The PR modifies 4 files:

    • support/awsapi/sqs.go — explicitly ignored by Codecov (support/awsapi/*.go)
    • test/e2e/nodepool_spot_termination_handler_test.go — explicitly ignored (test/**)
    • cmd/infra/aws/iam.go29.02% coverage, (ø) delta (IAM policy JSON string changes, not executable code paths)
    • cmd/infra/aws/delegatingclientgenerator/main.go0.00% coverage, (ø) delta (adds one string to a map literal)

The net result: -168 lines / -143 hits across the project are from indirect carry-forward drift, producing a -0.08% phantom drop that triggers the zero-tolerance default threshold.

Recommendations
  1. This failure is safe to ignore / override — The codecov/patch check passed, confirming the PR's own changes do not reduce coverage. The codecov/project failure is a false positive caused by carry-forward flag drift, not by this PR's code.

  2. Verify codecov/project is not a required check — Initial investigation suggests it is not a required status check on the main branch. If it is not required, the PR can be merged despite this failure.

  3. To fix permanently, add a project-level threshold tolerance to codecov.yml:

    coverage:
      status:
        project:
          default:
            threshold: 0.5%  # Allow up to 0.5% drop to absorb carry-forward drift
        patch:
          default:
            target: 100%
  4. Re-running the check or rebasing onto the latest main may also resolve the failure if the carry-forward data refreshes to align with the current base.

Evidence
Evidence Detail
Check conclusion codecov/project = failure; codecov/patch = success
Coverage delta 41.50% → 41.42% = -0.08%
PR files coverage impact All 4 files show (ø) — zero coverage change from PR code
Codecov bot message "✅ All modified and coverable lines are covered by tests"
Indirect changes 9 files with indirect coverage changes (not modified by PR)
Line count shift -168 lines, -143 hits (from indirect/carry-forward, not PR changes)
Carry-forward config All 5 flags have carryforward: true in codecov.yml
Threshold config No explicit coverage.status.project → Codecov defaults to 0% tolerance
codecov.yml ignores test/**, support/awsapi/*.go — 2 of 4 PR files are ignored
Base commit age a6c3012 from 2026-06-09 (same day, current main)
Recent PR comparison PRs #8696, #8701, #8489 all passed codecov/project

@openshift-ci

openshift-ci Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

@ratnam915: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@ratnam915

Copy link
Copy Markdown
Author

Request sent to AWS. See email: Request to Update AWS Managed IAM Policy for ROSA HCP - ROSANodePoolManagementPolicy

We will close this card.

@ratnam915 ratnam915 closed this Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cli Indicates the PR includes changes for CLI area/control-plane-operator Indicates the PR includes changes for the control plane operator - in an OCP release area/hypershift-operator Indicates the PR includes changes for the hypershift operator and API - outside an OCP release area/platform/aws PR/issue for AWS (AWSPlatform) platform area/testing Indicates the PR includes changes for e2e testing jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants